<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>Container operators</title>
  <link href="../cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td>
  <div class="body-content">

  <div class="header-box">
    <a href="../index.html">cppreference.com</a> &gt; <a href=
    "index.html">C++ Lists</a> &gt; <a href=
    "container_operators.html">Container operators</a>
  </div>

  <div class="name-format">
    Container operators
  </div>

  <div class="syntax-name-format">
    Syntax:
  </div>
  <pre class="syntax-box">
  #include &lt;list&gt;
  container operator=(const container&amp; c2);
  bool operator==(const container&amp; c1, const container&amp; c2);
  bool operator!=(const container&amp; c1, const container&amp; c2);
  bool operator&lt;(const container&amp; c1, const container&amp; c2);
  bool operator&gt;(const container&amp; c1, const container&amp; c2);
  bool operator&lt;=(const container&amp; c1, const container&amp; c2);
  bool operator&gt;=(const container&amp; c1, const container&amp; c2);
</pre>

  <p>All of the C++ containers can be compared and assigned with the
  standard comparison operators: ==, !=, &lt;=, &gt;=, &lt;, &gt;, and
  =. Performing a comparison or assigning one list to another takes
  <a href="../complexity.html">linear time</a>.</p>

  <p>Two lists are equal if:</p>

  <ol>
    <li>Their size is the same, and</li>

    <li>Each member in location i in one list is equal to the the
    member in location i in the other list.</li>
  </ol>

  <p>Comparisons among lists are done lexicographically.</p>

  <div class="related-name-format">
    Related topics:
  </div>

  <div class="related-content">
    (C++ Strings) <a href="../cppstring/string_operators.html">String
    operators</a><br>
    (C++ Strings) <a href="../cppstring/at.html">at</a><br>
    <a href="merge.html">merge</a><br>
    <a href="unique.html">unique</a>
  </div>
  </div>
  </td>
  


  </tr>
  </table>
</body></html>
